<?php
/***************************************************************************
 *   copyright : (C) 2009 Udrea Cristian
 *   site : http://code.google.com/p/testauction-php
 ***************************************************************************/

/***************************************************************************
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as 
 *   published by the Free Software Foundation; either version 2 of the
 *   License, or (at your option) any later version. Although none of the
 *   code may be sold. If you have been sold this script, get a refund.
 ***************************************************************************/
$contents="";
$template->setCurrentBlock("table_page");
/**
 * The user is already logged in, not allowed to register.
 */
if($session->logged_in){
	$contents .= "<p><b>$session->username</b>, esti deja inregistrat.</p>";
}
/**
 * The user has submitted the registration form and the
 * results have been processed.
 */
else if(isset($_SESSION['regsuccess'])){
   /* Registration was successful */
   if($_SESSION['regsuccess']){
      $contents .= "<p><b>".$_SESSION['reguname']."</b>, contul tau a fost creat si un e-mail a fost trimis catre adresa ta.</p>
	  <p>Acest e-mail contine instructiunile necesare pentru a iti activa contul.</p>";
   }
   /* Registration failed */
   else{
      $contents .= "<h1>Inregistrarea a esuat!</h1>".
		"<p>Regretam, dar o eroare a impiedicat inregistrarea contului cu userul <b>".$_SESSION['reguname'].
		"</b><br>Va rugam sa incercati mai tarziu.</p>";
   }
   unset($_SESSION['regsuccess']);
   unset($_SESSION['reguname']);
}else{
/**
 * The user has not filled out the registration form yet.
 * Below is the page with the sign-up form, the names
 * of the input fields are important and should not
 * be changed.
 */
	$contents .="<h3>De ce sa ma inregistrez?</h3><br />".
				"Doar utilizatorii inregistrati pot participa la licitatiile organizate de ".WEBSITE_NAME.".<br />".
				"<b>Fiecare utilizator are dreptul la un singur cont. ".
				"Crearea de conturi multiple va fi penalizata prin descalificarea utilizatorului din orice licitatie.".
				"<br /><br /><br />".
				"Pentru a va putea expedia produsele cumparate va rugam sa completati toate campurile de mai jos.</b><br />".
				"Dupa completarea formularului veti primi un email cu instructiuni de activare a contului.<div class=\"spacer\"></div>";
				
	if($form->num_errors > 0 && $form->value("subjoin")){
	   $contents .=  "<b style=\"color: red;\">Nu ati completat toate campurile necesare.</b>";
	}

	$contents .= "<form id=\"registerform\" action=\"process.php\" method=\"post\" style=\"color: black; font-weight: bold;\">".
		"<table style=\"align: left;\" border=\"0\" cellspacing=\"5\" cellpadding=\"3\">".
		"<tr><td colspan=\"3\"><input type=\"checkbox\" name=\"checkagree\" onclick=\"disableRegisterForm()\" ".($form->value("checkagree")?"checked=\"checked\"":"")." />Accept Termenii si Conditiile! <a href=\"#\">Termeni si conditii</a></td><td>".$form->error("checkagree")."</td></tr>".
		"<tr><td>Email &nbsp;</td><td><input type=\"text\" name=\"email\" maxlength=\"50\" value=\"".$form->value("email")."\" style=\"border: 1px solid\" ".(!$form->value("checkagree")?"disabled=\"disabled\"":"")." /></td><td>".$form->error("email")."</td></tr>".
		"<tr><td>Prenume &nbsp;</td><td><input type=\"text\" name=\"surname\" maxlength=\"50\" value=\"".$form->value("surname")."\" style=\"border: 1px solid\" ".(!$form->value("checkagree")?"disabled=\"disabled\"":"")." /></td><td>".$form->error("surname")."</td></tr>".
		"<tr><td>Nume &nbsp;</td><td><input type=\"text\" name=\"gname\" maxlength=\"50\" value=\"".$form->value("gname")."\" style=\"border: 1px solid\" ".(!$form->value("checkagree")?"disabled=\"disabled\"":"")." /></td><td>".$form->error("gname")."</td></tr>".
		"<tr><td>Nume de utilizator &nbsp;</td><td><input type=\"text\" name=\"user\" maxlength=\"30\" value=\"".$form->value("user")."\" style=\"border: 1px solid\" ".(!$form->value("checkagree")?"disabled=\"disabled\"":"")." /></td><td>".$form->error("user")."</td></tr>".
		"<tr><td>Parola &nbsp;</td><td><input type=\"password\" name=\"pass\" maxlength=\"30\" value=\"\" style=\"border: 1px solid\" ".(!$form->value("checkagree")?"disabled=\"disabled\"":"")." /></td><td>".$form->error("pass")."</td></tr>".
		"<tr><td>Repeta parola &nbsp;</td><td><input type=\"password\" name=\"repass\" maxlength=\"30\" value=\"\" style=\"border: 1px solid\" ".(!$form->value("checkagree")?"disabled=\"disabled\"":"")." /></td><td>".$form->error("repass")."</td></tr>".
		"<tr><td colspan=\"2\" align=\"right\">".
		"<input type=\"hidden\" name=\"subjoin\" value=\"1\"/>".
		"<button type=\"submit\" class=\"lime-button\" ".(!$form->value("checkagree")?"disabled=\"disabled\"":"")." >Trimite</button></td></tr>".
		"</table></form>";
}

$template->setVariable(TABLEPAGECONTENT, $contents);
$template->parseCurrentBlock();
?>
